package com.cmict.data.system.dal.mysql.conf;

import com.cmict.data.framework.common.pojo.PageResult;
import com.cmict.data.framework.mybatis.core.mapper.BaseMapperX;
import com.cmict.data.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cmict.data.system.controller.admin.conf.vo.ConfExportReqVO;
import com.cmict.data.system.controller.admin.conf.vo.ConfPageReqVO;
import com.cmict.data.system.dal.dataobject.conf.ConfDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 系统通用配置信息 Mapper
 * @author liutao
 * @date 2022/4/22
 */
@Mapper
public interface ConfMapper extends BaseMapperX<ConfDO> {

    default PageResult<ConfDO> selectPage(ConfPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ConfDO>()
                .eqIfPresent(ConfDO::getConfKey, reqVO.getConfKey())
                .eqIfPresent(ConfDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ConfDO::getType, reqVO.getType())
                .eqIfPresent(ConfDO::getConfValue, reqVO.getConfValue())
                .betweenIfPresent(ConfDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ConfDO::getId));
    }

    default List<ConfDO> selectList(ConfExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ConfDO>()
                .eqIfPresent(ConfDO::getConfKey, reqVO.getConfKey())
                .eqIfPresent(ConfDO::getDescription, reqVO.getDescription())
                .eqIfPresent(ConfDO::getType, reqVO.getType())
                .eqIfPresent(ConfDO::getConfValue, reqVO.getConfValue())
                .betweenIfPresent(ConfDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(ConfDO::getId));
    }

}
